# -*- coding: utf-8 -*-
import os
from urllib.request import urlretrieve


def pictureDown(IMAGE_URL):
    if len(IMAGE_URL.strip()) != 0:
        fileName = IMAGE_URL.rsplit('/', 1)[1]
        if not os.path.exists("./kl_Picture"):
            print("目录不存在")
            os.makedirs("./kl_Picture")
        else:
            # print("目录存在")
            storeName = './kl_Picture/' + fileName
            urlretrieve(IMAGE_URL, storeName)
            print(storeName + "：保存成功")
    else:
        print("没有图片地址")

if __name__ == '__main__':
    # IMAGE_URL = "http://cdnimg.kl.cc/memberpic/208494/208494_201911172314251160149717.jpg"
    # IMAGE_URL = "http://cdnimg.kl.cc/StaticF/SpacePhoto/sp_202006061445101631009216_228497_b.jpg"
    IMAGE_URL = " "
    pictureDown(IMAGE_URL)
